package com.appwoo.txtws.service;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.txtws.bean.StateBean;
import com.appwoo.txtws.bean.UserSettingBean;
import com.appwoo.txtws.component.DBHelper;
import com.appwoo.txtws.component.Global;
import com.appwoo.txtws.component.Logger;
import com.appwoo.txtws.component.RqSP;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import org.xmlpull.v1.XmlPullParserException;

public class RQSettings
{
  private Context context;
  private SharedPreferences.Editor editor;
  private SharedPreferences firSp;

  public RQSettings(Context paramContext)
  {
    this.context = paramContext;
    this.firSp = paramContext.getSharedPreferences("firstLogin", 0);
    this.editor = this.firSp.edit();
  }

  private void dealWithSetting()
  {
    SharedPreferences localSharedPreferences = this.context.getSharedPreferences("firstLogin", 0);
    try
    {
      str = getTimeStatus();
      if (str == "1")
      {
        if (Global.isSchool == 1)
          WebTimeControlService.sRate = Integer.parseInt(localSharedPreferences.getString("Sparaval", "120"));
        while (true)
        {
          if (WebTimeControlService.fRate != Global.oldRate)
            Global.rateChange = true;
          if (!Global.rateChange)
            break label252;
          if (!new RQSettings(this.context).bgADtcf(WebTimeControlService.fRate).equals("0"))
            break;
          Logger.e("xjf", "上报 更新频率['成功']--Global.rateChange:" + Global.rateChange + "\toldRate:" + Global.oldRate + "\tnewRate:" + WebTimeControlService.fRate);
          Global.rateChange = false;
          Global.oldRate = WebTimeControlService.fRate;
          return;
          WebTimeControlService.fRate = Integer.parseInt(localSharedPreferences.getString("Fparaval", "120"));
        }
      }
    }
    catch (Exception localException)
    {
      while (true)
      {
        String str;
        localException.printStackTrace();
        continue;
        if (str == "2")
        {
          if (Global.isSchool == 1)
            WebTimeControlService.sRate = 120;
          else
            WebTimeControlService.fRate = Integer.parseInt(localSharedPreferences.getString("Fparaval", "120"));
        }
        else
          WebTimeControlService.fRate = Integer.parseInt(localSharedPreferences.getString("Fparaval", "120"));
      }
      Logger.e("xjf", "上报 更新频率['失败']");
      return;
    }
    label252: Logger.e("xjf", "更新频率--无变化-rate:" + WebTimeControlService.fRate);
  }

  private String getTimeStatus()
  {
    String str1 = "0";
    try
    {
      DBHelper localDBHelper = new DBHelper(this.context);
      int i = localDBHelper.getSpecialTimeCount(Global.isBoarding);
      if ((Global.inHoliday == 0) && (Global.inLeave == 0) && (i == 0))
      {
        String str2 = localDBHelper.getSeniorTimeMin();
        String str3 = localDBHelper.getSeniorTimeMax();
        Date localDate1 = Global.transDateTime(Global.getTodayDate(this.context) + " " + str2);
        Date localDate2 = Global.transDateTime(Global.getTodayDate(this.context) + " " + str3);
        Date localDate3 = Global.transDateTime(Global.getDateAndTime(this.context));
        if ((localDate3.after(localDate1)) && (localDate3.before(localDate2)))
        {
          if (new RQScreenLock(this.context).checkSeniorTime(this.context, "1", Global.isBoarding))
          {
            str1 = "1";
            Logger.e("admin", "学校时间内(最早-" + str2 + "|最晚-" + str3 + ") +上课时间");
            return str1;
          }
          str1 = "2";
          Logger.e("admin", "学校时间内(最早-" + str2 + "|最晚-" + str3 + ") +课间时间");
          return str1;
        }
        Logger.e("admin", "非学校时间，");
      }
      return str1;
    }
    catch (Exception localException)
    {
    }
    return str1;
  }

  public void RQTimes(List<UserSettingBean> paramList)
  {
    int i = paramList.size();
    if (i > 0)
      Global.settingUpdate = true;
    for (int j = 0; ; j++)
    {
      if (j >= i)
      {
        dealWithSetting();
        return;
      }
      UserSettingBean localUserSettingBean = (UserSettingBean)paramList.get(j);
      if (localUserSettingBean.getType() != null)
      {
        String str1 = localUserSettingBean.getType();
        if ((str1.equals("0")) && (localUserSettingBean.getParaVal() != null) && (!localUserSettingBean.getParaVal().equals("")))
        {
          String str3 = localUserSettingBean.getParaVal();
          this.editor.putString("Fparaval", str3);
          this.editor.commit();
          Logger.e("admin", "家庭-更新频率为：" + str3);
        }
        if ((str1.equals("1")) && (localUserSettingBean.getParaVal() != null) && (!localUserSettingBean.getParaVal().equals("")))
        {
          String str2 = localUserSettingBean.getParaVal();
          this.editor.putString("Sparaval", str2);
          this.editor.commit();
          Logger.e("admin", "校园-更新频率为：" + str2);
        }
      }
    }
  }

  public void SaveLocal(List<UserSettingBean> paramList)
  {
    int i = paramList.size();
    int j;
    if (i > 0)
    {
      Global.settingUpdate = true;
      j = 0;
      if (j < i);
    }
    else
    {
      return;
    }
    UserSettingBean localUserSettingBean = (UserSettingBean)paramList.get(j);
    String str1 = localUserSettingBean.getParaVal();
    if (localUserSettingBean.getParaName().equalsIgnoreCase("synctime"))
    {
      if (localUserSettingBean.getType() != null)
      {
        String str2 = localUserSettingBean.getType();
        if ((str2.equals("0")) && (localUserSettingBean.getParaVal() != null) && (!localUserSettingBean.getParaVal().equals("")))
        {
          this.editor.putString("Fparaval", str1);
          this.editor.commit();
          Logger.e("admin", "家庭-更新频率为：" + str1);
        }
        if ((str2.equals("1")) && (localUserSettingBean.getParaVal() != null) && (!localUserSettingBean.getParaVal().equals("")))
        {
          this.editor.putString("Sparaval", str1);
          this.editor.commit();
          Logger.e("admin", "校园-更新频率为：" + str1);
        }
      }
      dealWithSetting();
    }
    while (true)
    {
      j++;
      break;
      if (localUserSettingBean.getParaName().equalsIgnoreCase("sleepset"))
      {
        this.editor.putString("SleepSet", str1);
        this.editor.commit();
        Logger.e("admin", "睡眠方式：" + str1);
      }
      else if (localUserSettingBean.getParaName().equalsIgnoreCase("notrace"))
      {
        this.editor.putString("NoTrace", str1);
        this.editor.commit();
        Logger.e("admin", "无痕模式：" + str1);
      }
      else if (localUserSettingBean.getParaName().equalsIgnoreCase("ManageLevel"))
      {
        try
        {
          new RqSP().setLeavel(Integer.parseInt(str1), this.context);
          Logger.e("admin", "管理级别：[1-高，0-低]=" + str1);
        }
        catch (Exception localException3)
        {
          localException3.printStackTrace();
        }
      }
      else if (localUserSettingBean.getParaName().equalsIgnoreCase("LocTime"))
      {
        try
        {
          new RqSP().setLocTime(str1, this.context);
          Logger.e("admin", "定位周期时间=" + str1);
        }
        catch (Exception localException2)
        {
          localException2.printStackTrace();
        }
      }
      else if (localUserSettingBean.getParaName().equalsIgnoreCase("LogSwitch"))
      {
        try
        {
          new RqSP().setLogSwitch(str1, this.context);
          if (str1.equals("1"))
          {
            this.editor = this.context.getSharedPreferences("SmsRecordsss", 0).edit();
            this.editor.putLong("sendsmss", Global.getServerTimeMills(this.context));
            this.editor.commit();
            this.editor = this.context.getSharedPreferences("SendCallss", 0).edit();
            this.editor.putLong("sendcallss", Global.getServerTimeMills(this.context));
            this.editor.commit();
          }
          Logger.e("admin", "记录开关=" + str1);
        }
        catch (Exception localException1)
        {
          localException1.printStackTrace();
        }
      }
    }
  }

  public String bgADtcf(String paramString)
  {
    try
    {
      StateBean localStateBean = new LoginService().UDUserSetting(Global.USERNAME, Global.getIMEI(this.context), "SyncTime", paramString, "0", this.context);
      if (localStateBean.getCode() != null)
      {
        String str = localStateBean.getCode();
        return str;
      }
      return "-1";
    }
    catch (IOException localIOException)
    {
      localIOException.printStackTrace();
      return "-2";
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      while (true)
        localXmlPullParserException.printStackTrace();
    }
    catch (TimeOutException localTimeOutException)
    {
      while (true)
        localTimeOutException.printStackTrace();
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      while (true)
        localNotFoundNetWorkException.printStackTrace();
    }
    catch (Exception localException)
    {
      while (true)
        localException.printStackTrace();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.service.RQSettings
 * JD-Core Version:    0.6.2
 */